#ifndef DATEDELEGATE_H
#define DATEDELEGATE_H

#include <QDate>
#include <QStyledItemDelegate>
#include <QDebug>

class DateFormatDelegate : public QStyledItemDelegate
{
public:
 DateFormatDelegate (QString dateFormat, QObject *parent = 0) :
  QStyledItemDelegate(parent),
  m_dateFormat(dateFormat)
 {
 }

 virtual QString displayText(const QVariant & value, const QLocale & locale ) const
 {
  Q_UNUSED(locale);
     QDate dt(QDate::fromString(value.toString(), "yyyy-MM-dd"));
  return dt.toString(m_dateFormat);
 }

private:
 QString m_dateFormat;
};

#endif // DATEDELEGATE_H
